package com.chandana.dev.tld;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * 
 * @author Chandana Napagoda
 * @version 0.1
 */

public class ShowPageNameTag extends TagSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String name;

	public ShowPageNameTag() {

	}

	@Override
	public int doStartTag() throws JspException {
		try {
			// get session data object
			HttpSession sessionData = pageContext.getSession();
			if (sessionData == null) {
				return SKIP_BODY;
			}

			String parameter = (String) sessionData
					.getAttribute(Constent.SHOW_MODULE_NAME);

			if (parameter != null && parameter.equalsIgnoreCase("true")) {
				JspWriter out = pageContext.getOut();
				out.print(name);
			}

		} catch (Exception ex) {
			return SKIP_BODY;
		}
		return SKIP_BODY;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
